//
//  AchievementService.m
//  playlive_sdk
//
//  Created by psvn047 on 5/16/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "AchievementService.h"

@implementation AchievementService
-(void) getAchievements: (NSString*) serviceId appId:(NSString*) appId onlyUnlocked:(BOOL) onlyUnlocked hiddenIncluded:(BOOL) hiddenIncluded
{
    NSString* path = [NSString stringWithFormat:@"achievement?app_id=%@&only_unlocked=%i&hidden_included=%i", appId,onlyUnlocked,hiddenIncluded];
    [self callService:serviceId httpMethod:@"GET" httpHost:[self getHTTPHost] path:path queryParameters:NULL messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
-(void) lock:  (NSString*) serviceId achievementCode:(NSString*) achievementCode
{
    NSString* path = [NSString stringWithFormat:@"achievement/lock?achievement_code=%@", achievementCode];
     [self callService:serviceId httpMethod:@"POST" httpHost:[self getHTTPHost] path:path queryParameters:NULL messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
-(void) unlock:(NSString*) serviceId achievementCode:(NSString*) achievementCode
{
    NSString* path = [NSString stringWithFormat:@"achievement/unlock?achievement_code=%@", achievementCode];
    [self callService:serviceId httpMethod:@"POST" httpHost:[self getHTTPHost] path:path queryParameters:NULL messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
-(void) deleteAchievement: (NSString*) serviceId achievementCode:(NSString*) achievementCode
{
    NSString* path = [NSString stringWithFormat:@"achievement?achievement_code=%@", achievementCode];
    [self callService:serviceId httpMethod:@"DELETE" httpHost:[self getHTTPHost] path:path queryParameters:NULL messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
-(void) create: (NSString*) serviceId appId:(NSString*) appId achievementCode:(NSString*)achivementCode titles:(NSMutableArray*) titles descriptionBefore:(NSMutableArray*) descriptionBefore descriptionAfter:(NSMutableArray*) descriptionAfter value:(int) value isHidden:(BOOL) isHidden
{
    NSMutableDictionary * query = [NSMutableDictionary dictionary];
    [query setObject:appId forKey:@"app_id"];
    [query setObject:achivementCode forKey:@"achivement_code"];
    [query setObject:[NSString stringWithFormat:@"%i", value] forKey:@"value"];
    
    if(isHidden) [query setObject:[NSString stringWithFormat:@"%i", isHidden] forKey:@"is_hidden"];
    
    [query setObject:titles forKey:@"title"];
    [query setObject:descriptionBefore forKey:@"description_before"];
    [query setObject:descriptionAfter forKey:@"description_after"];
    
     [self callService:serviceId httpMethod:@"POST" httpHost:[self getHTTPHost] path:@"achievement" queryParameters:query messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
@end
